<template>
  <div class="hello" :a="msg" @click="msg = 'abc'">
    <!-- 生成vnode后，这些属性绑定以及大胡子语法会消失 -->
    {{ msg }}
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  // 如果有上面的模板和render函数，vue-cli会将模板预编译覆盖render
  render(h) {
    return h(
      "div",
      {
        class: "hello", // 模板编译的vnode是staticClass，这里是class，细节不用管
        attrs: {
          a: this.msg,
        },
        on: {
          click: () => {
            this.msg = "abc"; // 不能直接改属性，报错
          },
        },
      },
      this.msg
    );
  },
  mounted() {
    console.log("HelloWorld", this._vnode); // 可以看下生成的虚拟dom
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
